<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Form extends CI_Controller {

	function __construct()
	{
		parent::__construct();

		$this->load->helper('url');
	
	}
	
	function index()
	{
		$this->load->library('form_validation');
		
		$this->form_validation->set_rules('username', '用户名', 'required');
		$this->form_validation->set_rules('demo', 'demo', 'required');
		$this->form_validation->set_rules('quantity', '', '');
		$this->form_validation->set_rules('mycheck[]', '', '');
		$this->form_validation->set_rules('myradio', '', '');
		$this->form_validation->set_rules('shirts', '', '');

		
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
			
		if ($this->form_validation->run() == FALSE)
		{
			$config['title'] = 'test form';
			$this->load->view('test_form', $config);
		}
		else
		{
			//$array['title'] = 'submit success';
			//$this->load->view('test_form', $array);
			//echo $this->input->post('username')."<br/>";
			//print_r($this->input->post('mycheck')) . "<br/>";
			redirect('form/form_success');
		}	
		
		//$this->load->view('test_form');
		
	}
	function form_success()
	{
		echo 'success'."<br/>";		
		echo anchor('form', 'back to form');
		
	}
}